{ Siberian Olympiad. 1 stage.
  Problemset: http://agul-problems1.googlecode.com/svn/trunk/2010-2011/wso/stage1/wso_1stage.pdf
  Problem 1
  Points: 65
}
var t:array [1..1001] of longint; otrez:array [1..1001, 1..2] of longint; n,m,i,l,lk,j:longint;
Begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do begin
	readln(l);
	t[i]:=l;
end;
for i:=1 to m do begin
	readln(l,lk);
	otrez[i,1]:=l;
	otrez[i,2]:=lk;
end;
for i:=1 to n do begin
	lk:=1;
	for j:=1 to m do
	  if (lk<>0) and (otrez[j,1]<=t[i]) and (otrez[j,2]>=t[i]) then begin
		  l:=j;
		  lk:=0;
		  otrez[j,1]:=-999999;
		  otrez[j,2]:=-999999;
	  end;
	writeln(l);
end;
close(output);
end.